#!/usr/bin/env node

const http=require('http'),
      log=console.log;

const html=`<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
    <title></title>
    </head>
    <body>
    
    <form action="">
      <lable>用户名：</lable>
      
        <input type="text name='username'">
          <br>
          
            <lable>密码:</lable>
              <input type="password" name='password'>
                <br>
                
                
                  <input type="button" value='登录'>
                    <br>
                    </form>
                      
                    </body>
                    </html>
                    `;
http.createServer((req,res)=>{
  if(req.url!=='/'){
    res.statusCode=404;
    res.setHeader('Content-Type','text/html');
    res.end('<h1>Not Found</h1>')
    return
  }

  res.writeHead(200,{
    'Content-Type':'text/html',
    'Content-Length':Buffer.byteLength(html)
  });
  //设置头部信息
  /*
  res.statusCode=200;
  res.setHeader('Content-Type','txt/html');
  res.setHeader('Content-Length',Buffer.byteLength(html));
  res.end(html);
  */
  res.end(html);
  

}).listen(8080)
